package leetcode.offer;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021/11/16
 */
public class offer50 {



    @Test
    public void test() {
       String s = "abaccdeff";
        System.out.println(firstUniqChar(s));
    }

    public char firstUniqChar(String s) {
       Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i <s.length(); i++) {
            map.put(s.charAt(i),map.getOrDefault(s.charAt(i),0)+1);
        }
        for (char c : s.toCharArray()) {
            if(map.get(c)==1){
                return c;
            }
        }
        return ' ';
    }
}
